package com.eunion.web.admin.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.eunion.web.admin.entity.AdminUser;
import com.eunion.web.common.base.BaseRepository;

/**
 * @see AdminUser .
 *
 */
public interface AdminUserRepository extends BaseRepository<AdminUser,String> {

    /**
     * 查找，用于用户登录
     */
	AdminUser findOneByUsernameAndPassword(String username,String password);

    /**
     * 根据用户名查询.
     */
	AdminUser findOneByUsername(String username);

    /**
     * 重置密码.
     */
    @Modifying
    @Query(value = "update  admin_user set password = 'e10adc3949ba59abbe56e057f20f883e'  where username  =?1 ", nativeQuery = true)
    int resetPassword(String username);

    /**
     * 修改密码.
     */
    @Modifying
    @Query(value = "update  admin_user set password = ?1  where username  =?2  and password = ?3", nativeQuery = true)
    int updatePassword(String newPwd,String username,String password);

}
